Skip to content

feat(ldap): Allow to search one user by one of its LDAP attribute#59928

Open
CarlSchwan wants to merge 1 commit intomasterfrom
carl/ldap-search-one-by-attribute
Open

feat(ldap): Allow to search one user by one of its LDAP attribute#59928
CarlSchwan wants to merge 1 commit intomasterfrom
carl/ldap-search-one-by-attribute

Conversation

@CarlSchwan
Copy link
Copy Markdown
Member

@CarlSchwan CarlSchwan commented Apr 27, 2026

Summary

Part of #55284

Alternative to #56721

Related PRs:

Checklist

AI (if applicable)

  • The content of this PR was partly or fully generated using AI

@CarlSchwan CarlSchwan added this to the Nextcloud 34 milestone Apr 27, 2026
@CarlSchwan CarlSchwan self-assigned this Apr 27, 2026
@CarlSchwan CarlSchwan requested a review from a team as a code owner April 27, 2026 12:05
@CarlSchwan CarlSchwan requested review from come-nc, nfebe, salmart-dev and sorbaugh and removed request for a team April 27, 2026 12:05
@CarlSchwan CarlSchwan force-pushed the carl/ldap-search-one-by-attribute branch from f8d70a0 to 15f4ff4 Compare April 27, 2026 16:05
Comment thread lib/public/LDAP/Exceptions/MultipleUsersReturnedException.php
Comment thread apps/user_ldap/lib/User_LDAP.php
Comment thread apps/user_ldap/lib/User_LDAP.php Outdated
@CarlSchwan CarlSchwan force-pushed the carl/ldap-search-one-by-attribute branch 3 times, most recently from 9bc4600 to 5388b92 Compare May 6, 2026 13:30
Comment thread apps/user_ldap/lib/User_LDAP.php Outdated
@CarlSchwan CarlSchwan force-pushed the carl/ldap-search-one-by-attribute branch from 5388b92 to c47f679 Compare May 7, 2026 10:57
Comment thread apps/user_ldap/lib/User_LDAP.php Outdated
$records = $this->access->searchUsers($filter, ['dn']);
$this->logger->error($filter);
if (count($records) === 1) {
return $this->access->dn2username($records[0]['dn'][0]);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

According to psalm you need to convert false into null here

Suggested change
return $this->access->dn2username($records[0]['dn'][0]);
return $this->access->dn2username($records[0]['dn'][0]) ?: null;

But if you do it like this it will most likely complain about falsy string 🙈

Signed-off-by: Carl Schwan <carlschwan@kde.org>
@CarlSchwan CarlSchwan force-pushed the carl/ldap-search-one-by-attribute branch from c47f679 to 1b35170 Compare May 7, 2026 15:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants